import { request } from '@umijs/max';
import type { Tag, TagFilterCondition } from '../tags/typing';
import type { MsgResponse, PagedDataResponse } from '../typing';

// 分页获取标签列表
export function filtertTagsList(params: TagFilterCondition) {
  return request<Promise<PagedDataResponse<Tag>>>('/api/tags', {
    method: 'GET',
    params,
  });
}

// 删除单个标签
export function deleteTag(tag_id: number) {
  return request<Promise<MsgResponse>>(`/api/tags/${tag_id}`, {
    method: 'DELETE',
  });
}

// 创建标签
export function createTag(tag_name: string) {
  return request<Promise<MsgResponse>>('/api/tags', {
    method: 'POST',
    data: { tag_name },
  });
}

// 批量删除标签
export function batchDeleteTags(tags: Tag[]) {
  return request<Promise<MsgResponse>>('/api/tags', {
    method: 'DELETE',
    data: tags,
  });
}
